package org.one.afternoon.controller;

import lombok.extern.slf4j.Slf4j;
import org.one.afternoon.common.Result;
import org.one.afternoon.provider.xunfei.WebIATWSListener;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/iat")
@Slf4j
public class IATController {
    @CrossOrigin
    @PostMapping("/kdxf")
    @ResponseBody
    public Result<String> connect(@RequestParam String audio) {
        //  log.info("解码后->"+ Arrays.toString(Base64.getDecoder().decode(audio)));
        log.info("音频长度-->"+audio.length());
        log.info("需要解析的音频-->"+audio);
        try {
         // WebIATWS.connect(Base64.getDecoder().decode(audio));
        //  WebIATWS.connect(audio.getBytes());
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        while(true) {
            if(WebIATWSListener.end) break;
        }
        return Result.success(WebIATWSListener.result);
    }
}
